/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.totoBD.gui.swing.components.dialog;

import com.totoBD.gui.swing.components.checkbox.CbxUseAllDataBases;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

/**
 *
 * @author rgil
 */
public abstract class DlgConUserAbs extends DlgConAbs implements ActionListener{

    public DlgConUserAbs(
            String title,
            String textDescription,
            String actVerb,
            Frame parent,
            boolean modal) throws Exception{
        super(textDescription, parent, modal);
        this.blnUseAllDataBases = false;
        this.txfUserName = new JTextField();
        this.txfDataBaseName = new JTextField();
        this.lblUseDataBase = new JLabel("On the following database :");
        this.cbxUseAllDataBases = new CbxUseAllDataBases(actVerb + " rights to this user on all databases", super.lst_);
        Dimension dim = new Dimension (400,210);
        this.setTitle(title);
        this.setMinimumSize(dim);
        this.setSize(dim);
        
    }
    @Override
    protected abstract boolean _doJob() throws Exception;


    @Override
       public void actionPerformed(ActionEvent e) {

       if (e.getSource() instanceof CbxUseAllDataBases)
       {
           if(!this.blnUseAllDataBases)
           {
                this.txfDataBaseName.setEnabled(false);
                this.lblUseDataBase.setEnabled(false);
                this.blnUseAllDataBases=true;
           }
           else if (this.blnUseAllDataBases)
           {
                this.txfDataBaseName.setEnabled(true);
                this.lblUseDataBase.setEnabled(true);
                this.blnUseAllDataBases=false;
           }
       }
       super.actionPerformed(e);
   }


    protected JTextField txfUserName;
    
    protected boolean blnUseAllDataBases;
    protected JLabel lblUseDataBase;
    protected JCheckBox cbxUseAllDataBases;



}
